<template>
  <div>
    <h3>陈帅鹏黑店</h3>
    <HmChen
      v-for="item in list"
      :key="item.id"
      :menu="item"
      @Lowprice="fatherLowprice"
    />
  </div>
</template>

<script>
import HmChen from './SonComponent.vue'
export default {
  name: 'FatherComponent',
  components: {
    HmChen,
  },
  data() {
    return {
      list: [
        {
          id: 1,
          proname: '超级好吃棒棒糖',
          proprice: 188,
          low: 160,
          desc: '甜',
        },
        {
          id: 2,
          proname: '超级好吃的大鸡腿',
          proprice: 360,
          low: 320,
          desc: '香',
        },
        { id: 3, proname: '超级无敌冰激凌', proprice: 42, low: 30, desc: '冰' },
      ],
    }
  },
  methods: {
    fatherLowprice(id, num) {
      this.list.forEach((item) => {
        if (item.id === id)
          item.proprice > 0
            ? (item.proprice -= num)
            : alert('亏本啦，求求别点了')
      })
    },
  },
}
</script>

<style></style>
